<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	//String t = (String)session.getAttribute("Manage_Roles");
//if(t!="active")
	//{response.sendRedirect("index.jsp");}
%>
<%@page import="java.util.List"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.Date"%>
<%@page import="iwpl.project.entities.Roles"%>
<%@page import="iwpl.project.dao.*"%>
<%@page import="iwpl.project.interfaces.*"%>
<%@page import="iwpl.project.servlet.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<center>
	<script type="text/javascript">
	function Confirm(id) {
		var text = confirm("Are you sure ?");

		if (text == true) {
			//alert("Okey, Deleted !!!");
			location.href = "./servlet/Control_Role?rID="+id+"&action=Delete";
		} else {
			alert("What ever !!!");
		}
	}
</script>
	<html>
		<head>
			<base href="<%=basePath%>">

			<title>Manage Role</title>

			<meta http-equiv="pragma" content="no-cache">
			<meta http-equiv="cache-control" content="no-cache">
			<meta http-equiv="expires" content="0">
			<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
			<meta http-equiv="description" content="This is my page">
			<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
			<style type="text/css">
.styleTemplate1 {
	width: 100%;
	height: 142px;
}

.styleTemplate2 {
	width: 300px;
}
</style>
		</head>

		<body>
			<form name="frmManageRole" action="./servlet/Control_Role"
				method="get">
				<table cellpadding="0" cellspacing="0">
					<tr>
						<td>

							<table align="center">
								<tr>
									<td colspan="5" align="center">
										Manage Roles
									</td>
								</tr>
								<tr>
									<td colspan="5">
										<a href="Insert_Role.jsp">Insert</a>
									</td>
								</tr>
								<tr bgcolor="5f9ff5">
									<td>
										No
									</td>
									<td>
										RoleName
									</td>
									<td>
										Descriptions
									</td>
									<td>
										Active
									</td>
									<td>
										Edit
									</td>
									<td>
										Delete
									</td>
									<td>
										Detail
									</td>
								</tr>
								<%
											RolesDAO dao = new RolesDAO();
											List<Roles> list = dao.findAll();

											int i = 0;

											for (Iterator<Roles> it = list.iterator(); it.hasNext();) {
												Roles rol = (Roles) it.next();
												i++;

												if (i % 2 != 0) {
													out.println("<tr bgcolor=\"#CCFFFF\"><td>");
												} else {
													out.println("<tr bgcolor=\"#99CCCC\"><td>");
												}
												out.println(i + "</td>");
												out.println("<td>" + rol.getRoleName() + "</td>");
												out.println("<td>" + rol.getDescription() + "</td>");
												out.println("<td>" + rol.getActive() + "</td>");

												//	out.println("<td>" + apart.getValue() + "</td>");
												//out.println("<td>" + rsq.getString("CountID") + "</td></tr>");
												//out.println("<td>" + rs.getString("Status") + "</td></tr>");
												out.println("<td><a href="
														+ "/DepartmentManage/Update_Role.jsp?rid="
														+ rol.getId().toString() + " /><img src="
														+ "./images/Edit.jpg" + " /></td>");
												/*out.println("<td><a href=" + "./servlet/myservlet?delete="
														+ rs.getString("CategoryID") + " /><img src="
														+ "./Pics/Delete.jpg" + " /></td></tr>");*/
												//out.println("<td><img src=\"./Pics/Delete.jpg\" onclick =\"Confirm()\"/></td></tr>");
												out.println("<td><a href=javascript:Confirm('"+rol.getId()
														+ "') /><img src=" + "./images/Delete.jpg"
														+ " /></td>");
												out.println("<td><a href="
														+ "/DepartmentManage/Manage_RoleDetails.jsp?rold="
														+ rol.getId()+"><img src="
														+ ".images/Report1.png" + " /></td></tr>");

											}
										%>
							</table>

						</td>
					</tr>
					<tr>
						<td>
							<%
											if(request.getParameter("message")!=null)
											{
												String a = request.getParameter("message").toString();
												out.print(a);
											}
										 %>
						</td>
					</tr>
				</table>
			</form>
		</body>
	</html>
</center>